<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" name="viewport" />
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no">
    <meta charset="UTF-8" name="apple-itunes-app" content="app-id=7777777, affiliate-data=myAffiliateData, app-argument=yourScheme://">
    <title>Pay</title>
    <link rel="stylesheet" href="./css/index.css">
    <style>
        .assign-pay{
            padding: 1rem;
            max-width: 720px;
            margin: auto;
            padding-bottom: 3rem;
        }
        .assign-head{
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 1rem;
        }
        .assign-head p{
            font-size: .8rem;
            color: #999999;
        }
        .assign-head p a{
            color: #666666;
        }
        .assign-head p:first-child{
            width: 8rem;
        }
        .assign-head p img{
            width: 100%;
        }
        .assign-banner img{
            width: 100%;
        }
        .assign-money,.assign-select{
            border: 1px solid #dde7f0;
            border-radius:.75rem;
            padding: 0 1rem;
            margin-bottom:1rem;
        }
        .assign-money p{
            display: flex;
            justify-content: space-between;
            font-size: 1rem;
            margin-top: 1rem;
        }
        .assign-money div{
            display: flex;
            justify-content: space-between;
            border-top: 1px solid #dde7f0;
            margin-top: 1rem;
            padding: 1rem 0;
        }
        .assign-money div input{
            width: 71%;
            border: none;
            background: none;
            outline: none;
            text-align: right;
            padding: 0 2%;
            font-size: 1.2rem;
        }
        .assign-select{
            padding: 1rem;
        }
        .assign-money div span{
            width: 25%;
            font-size: 1rem;
        }
        .assign-tips p{
            font-size: 1rem;
        }
        .assign-tips p span{
            font-size: .8rem;
            color: #999;
        }
        .select-all{
            display: flex;
            justify-content: space-between;
            padding: 1.25rem;
            border-radius: .5rem;
            border: 1px solid #dde7f0;
            margin: 1rem 0;
        }
        .select-all:last-child{
            margin:0;
        }
        .select-all p:first-child{
            display: flex;
            align-items: center;
        }
        .select-all p{
            font-size: 1rem;
        }
        .select-all p img{
            width: 1.2rem;
            height: 1.2rem;
            margin-right: .625rem;
        }
        .active{
            border-color: #ffb99f;
            background-color: #fff7f2;
        }
        .assign-buttom{
            position: fixed;
            bottom: 0;
            left: 0;
            background: #543f24;
            border-color: #543f24;
            padding: .8rem 0;
            margin: 0 auto;
            width: 100%;
            color: #fff;
            text-align: center;
            font-size: 1.2rem;
        }
    </style>
</head>
<body>
<div class="assign-pay" id="app" style="display: none">
    <div class="assign-head">
        <p><img src="./img/logos.png" alt=""></p>
        <p>Email:<a href="mailto:server@boss-pay.in">service@boss-pay.in</a></p>
    </div>
    <div class="assign-money">
        <p><span>Order</span><s id="order">160904250340029850</s></p>
        <div><span>Total</span><input disabled id="oldaccount" type="number"></input>INR</div>
    </div>
    <div class="assign-select">
        <div class="assign-tips">
            <p>Payment methods</p>
            <p><span>Choose a payment method to pay</span></p>
        </div>
        <div class="select-all active" value="5">
            <p>
                <img src="./img/icon-upi.svg" alt="">
                <span>UPI</span>
            </p>
            <p>
                <svg data-v-9d4ce622="" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16"><g stroke-width="1" stroke="currentColor" class="nc-icon-wrapper"><polyline fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" points="4.5,0.5 12,8 4.5,15.5 "></polyline></g></svg>
            </p>
        </div>
        <div class="select-all" value="3">
            <p>
                <img src="./img/icon-wallet.svg" alt="">
                <span>Wallet</span>
            </p>
            <p>
                <svg data-v-9d4ce622="" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16"><g stroke-width="1" stroke="currentColor" class="nc-icon-wrapper"><polyline fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" points="4.5,0.5 12,8 4.5,15.5 "></polyline></g></svg>
            </p>
        </div>
        <div class="select-all" value="1">
            <p>
                <img src="./img/icon-card.svg" alt="">
                <span>Card</span>
            </p>
            <p>
                <svg data-v-9d4ce622="" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16"><g stroke-width="1" stroke="currentColor" class="nc-icon-wrapper"><polyline fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" points="4.5,0.5 12,8 4.5,15.5 "></polyline></g></svg>
            </p>
        </div>
        <div class="select-all" value="2">
            <p>
                <img src="./img/icon-net-banking.svg" alt="">
                <span>Net Banking</span>
            </p>
            <p>
                <svg data-v-9d4ce622="" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16"><g stroke-width="1" stroke="currentColor" class="nc-icon-wrapper"><polyline fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" points="4.5,0.5 12,8 4.5,15.5 "></polyline></g></svg>
            </p>
        </div>
        <div class="assign-buttom" style="display: none" onclick="UrlMerChannel()">
            <span>Pay Now</span>
        </div>
    </div>
</div>

<div>
    <div id="name" style="text-align: center;margin-top: 50px;font-size: 20px;display: none">
        提示：请用手机端H5支付
    </div>
    <!--    style="display: none"  -->
    <div id="name1" class="pay_all" style="display: none">
        <h2>聚合支付</h2>
        <div class="head">
            <div id="qrcode"></div>
            <p id="jietu" style="font-size: 1.2rem;color: red;text-align: center;display:none;margin-top: 10px">请先截图二维码</p>
            <p class="jin" style="text-align: center;margin-top: 10px">金额：<s id="account"></s></p>
            <span class="red">请在 <s id="teday"></s> 之前支付完成</span>
            <a onclick="zhifubao()" id="zhif">启动支付宝支付</a>
            <!--            <a onclick="weixin()" class="wx">测试</a>-->
            <!--            <span>Tips：微信支付请截图二维码</span>-->
            <a onclick="weixin()" class="wx" id="wx" style="display: none">启动微信</a>
            <h1>注意</h1>
            <p>1.请及时付款以免造成不必要的损失，掉单请联系客服补单</p>
            <p id="zhifbao">2.也可以手机截图，支付宝扫一扫，从相册选中识别二维码进行支付</p>
            <p id="weixin" style="display: none">2.请截图，启动使用微信扫一扫直接付款</p>
        </div>
    </div>
</div>
</body>
<script type="text/javascript" src="https://checkout.razorpay.com/v1/checkout.js"></script>
<script src="js/url.js"></script>
<script src="./js/jquery.1.3.js"></script>
<script>
    var urlAll = ''
    function getRequestParams(param){
        var reg = new RegExp("(^|&)" + param + "=([^&]*)(&|$)", "i");
        var r = window.location.search.substr(1).match(reg);
        if (r != null) return unescape(r[2]);
        return null;
    }
    function _isMobile() {
        let flag = navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i)
        return flag;
    }

    function qrcode(id,url){
        let qrcode = new QRCode(id, {
            width : 250,
            height : 250
        });
        qrcode.makeCode(url)
    }

    function IsPC() {
        var userAgentInfo = navigator.userAgent;
        var Agents = ["Android", "iPhone",
            "SymbianOS", "Windows Phone",
            "iPad", "iPod"];
        var flag = true;
        for (var v = 0; v < Agents.length; v++) {
            if (userAgentInfo.indexOf(Agents[v]) > 0) {
                flag = false;
                break;
            }
        }
        return flag;
    }


    function toCode(str) {  //加密字符串
        //定义密钥，36个字母和数字
        var key = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
        var len = key.length;  //获取密钥的长度
        var a = key.split("");  //把密钥字符串转换为字符数组
        var s = "",b, b1, b2, b3;  //定义临时变量
        for (var i = 0; i <str.length; i ++) {  //遍历字符串
            b = str.charCodeAt(i);  //逐个提取每个字符，并获取Unicode编码值
            b1 = b % len;  //求Unicode编码值得余数
            b = (b - b1) / len;  //求最大倍数
            b2 = b % len;  //求最大倍数的于是
            b = (b - b2) / len;  //求最大倍数
            b3 = b % len;  //求最大倍数的余数
            s += a[b3] + a[b2] + a[b1];  //根据余数值映射到密钥中对应下标位置的字符
        }
        return s;  //返回这些映射的字符
    }
    function weixin(){
        window.location.href = 'weixin://'
    }
    function UrlMerChannel(){
        var u = navigator.userAgent, app = navigator.appVersion;
        var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Linux') > -1; //如果输出结果是true就判定是android终端或者uc浏览器
        var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //根据输出结果true或者false来判断ios终端
        let obj = {orderid:getRequestParams('orderid'),systemType:'',methods:methods}//this.orderid
        if(isAndroid){
            console.log("安卓手机进来的");
            obj.systemType = 1
        }else if(isiOS){
            console.log("苹果手机进来的");
            obj.systemType = 1
        }else if(IsPC()){
            console.log("web端");
            obj.systemType = 5
        }
        $.ajax({
            url:urls,
            type:'get',
            data:obj,
            success:function(res) {
                console.log(res)
                if(res.code == 200){
                    if(res.data.types == 8){
                        document.write(res.data.checkstand)
                        $('#name1').hide()
                    }
                    if(res.data.types == 4){
                        if(res.data.number == 1 || res.data.number == 2){
                            $('#name1').show()
                            $('#account').html(res.data.amount)
                            urlAll = 'alipays://platformapi/startapp?saId=20000917&url='+encodeURIComponent(res.data.checkstand)
                            window.location.href = 'alipays://platformapi/startApp?appId=20000917&url='+encodeURIComponent(res.data.checkstand)
                            qrcode(document.getElementById("qrcode"),res.data.checkstand)
                            $('#teday').html(format(new Date(),0))
                        }
                        if(res.data.number == 3){
                            location.replace(res.data.checkstand);
                            $('#name1').hide()
                        }
                        if(res.data.number == 4){
                            document.write(res.data.checkstand)
                        }
                        if(res.data.number == 6){
                            $('#weixin').hide()
                            $('#name1').show()
                            $('#account').html(res.data.amount)
                            urlAll = 'alipays://platformapi/startapp?appId=20000917&url='+encodeURIComponent(res.data.checkstand)
                            window.location.href = 'alipays://platformapi/startApp?appId=20000917&url='+encodeURIComponent(res.data.checkstand)
                            qrcode(document.getElementById("qrcode"),res.data.checkstand)
                            $('#teday').html(format(new Date(),0))
                            setTimeout(()=>{
                                location.replace(urlAll)
                            },200)
                        }
                        if(res.data.number == 7 || res.data.number == 8){
                            window.location.href = res.data.checkstand
                        }
                        if(res.data.number == 9){
                            location.replace(res.data.checkstand)
                        }
                        if(res.data.number == 10){
                            document.write(res.data.checkstand)
                            $('#name1').hide()
                        }
                    }
                    if(res.data.types == 1){
                        if(res.data.number == 200){
                            $('#zhifbao').hide()
                            $('#zhif').hide()
                            $('#weixin').show()
                            $('#name1').show()
                            $('#wx').show()
                            $('#jietu').show()
                            $('#account').html(res.data.amount)
                            qrcode(document.getElementById("qrcode"),res.data.checkstand)
                            $('#teday').html(format(new Date(),0))
                        }else if(res.data.number == 201){
                            $('#zhifbao').hide()
                            $('#zhif').hide()
                            $('#weixin').show()
                            $('#name1').show()
                            $('#wx').show()
                            $('#jietu').show()
                            $('#account').html(res.data.amount)
                            qrcode(document.getElementById("qrcode"),res.data.checkstand)
                            $('#teday').html(format(new Date(),0))
                        }
                    }
                    if(res.data.types == 7){
                        if(res.data.number == 305 || res.data.number == 324 || res.data.number == 329){
                            // var script = document.createElement("script");
                            // script.type = "text/javascript";
                            // script.src = "https://checkout.razorpay.com/v1/checkout.js";
                            // document.head.appendChild(script);
                            var options = JSON.parse(res.data.checkstand)
                            setTimeout(function (){
                                var rzp1 = new Razorpay(options);
                                function main() {
                                    rzp1.open();
                                }
                                // main()
                                window.onload = main()
                            },300)
                        }else if(res.data.number == 306){
                            // console.log(res.data.checkstand)
                            location.replace(res.data.checkstand)
                        }else if(res.data.number == 328 ||res.data.number == 323 || res.data.number == 308 || res.data.number == 320 || res.data.number == 322 || res.data.number == 325 || res.data.number == 327){
                            if(res.data.checkstand != ''){
                                location.replace(res.data.checkstand)
                            }
                        }else {
                            // console.log(res.data.checkstand)
                            document.write(res.data.checkstand)
                            $('#name1').hide()
                        }
                    }
                    if(res.data.types == 10 || res.data.types ==6){
                        location.replace(res.data.checkstand)
                    }
                    if(res.data.types == 16 || res.data.types == 17 || res.data.types == 18 || res.data.types == 19 || res.data.types == 20 || res.data.types == 21 || res.data.types == 22 || res.data.types == 23 || res.data.types == 24){
                        document.write(res.data.checkstand)
                        $('#name1').hide()
                    }
                    if(res.data.types == 13){
                        if(res.data.checkstand != ''){
                            window.location.href = './upipay.html?data='+ toCode(res.data.checkstand)
                        }else {
                            alert('error！')
                        }
                    }
                }else {
                    alert('data error！')
                }
            },
            error:function(error){
                alert(JSON.parse(error.responseText).msg)
            }
        })
    }

    function format(date,day) {
        var nd = date
        nd = nd.valueOf()
        nd = nd + day * 24 * 60 * 60 * 1000 + 60*5 * 1000
        nd = new Date(nd)
        var y = nd.getFullYear()// 获取年
        var m = nd.getMonth() + 1// 获取月
        var d = nd.getDate()// 获取天
        var h = nd.getHours()// 获取小时
        var f = nd.getMinutes()// 获取分钟
        var s = nd.getSeconds()// 获取秒
        if (m <= 9) m = '0' +m
        if (d <= 9) d = '0' +d
        if (h <= 9) h = '0' +h
        if (f <= 9) f = '0' +f
        if (s <= 9) s = '0' +s
        const cdate = y + '-' +m + '-' +d + ' '+h + ':' +f + ':' +s
        return cdate
    }

    // if(_isMobile()){
    //     UrlMerChannel()
    // }else {
    //     UrlMerChannel()
    //     // $('#name1').hide()
    //     // $('#name').show()
    // }

    //启动支付宝,并跳转到付款页面
    function zhifubao(){
        location.replace(urlAll)
    }
    var methods = 5
    $('.select-all').on('click',function (){
        methods = $(this).attr('value')
        $(this).addClass('active').siblings().removeClass('active')
        $('.assign-buttom').show()
    })
    var dataALL = ''
    function initAll(){
        let obj = {orderid:getRequestParams('orderid')}
        $.ajax({
            url: getOrder,
            type: 'get',
            data: obj,
            success: function (res) {
                dataALL = res.data
                $('#order').html(res.data.terraceordercode)
                $('#oldaccount').val(res.data.oldaccount)
                if(res.data.types == 1){
                    $('#app').show()
                }else {
                    $('#app').hide()
                    UrlMerChannel()
                }
            },
        })
    }
    initAll()


</script>
</html>
